home *** CD-ROM | disk | FTP | other *** search
- // SerialTest.c
-
- // ©Copyright 1987 Consulair Corp. All rights reserved
-
- /* This program does a simple serial loop test, reading characters from
- the keyboard and sending them out port B (the printer port), and
- receiving them from port A (the modem port). In order to run it, you
- need a cable which connects ports A and B through a "null modem", i.e.
- the cable must have the send and receive lines swapped at one end.
- Note that port A is opened for output even though it will only be used
- for input. This is because the serial driver is only initialized
- when a port is opened for output. Also notice the use of the feof
- function on either the keyboard (stdin) or a serial port. It returns
- true if there are no characters buffered for the device, and false
- if there are characters buffered.
- */
-
- #include <stdio.h>
-
- main()
- {
- char c;
- FILE *fileIn, *fileOut;
- fileIn = fopen(".Aout", "W"); // open output to initialize the driver.
- if ((fileIn = fopen(".Ain", "R")) == 0)
- {
- printf("\rCould Not Open Input");
- getchar();
- ExitToShell();
- }
- if (fileOut = fopen(".Bout", "W"))
- {
- printf("\rOutput and Input are Open. Type Any character\rClick Mouse Button to Quit.\r");
- while (1)
- {
- if (!feof(stdin)) outch(fileOut, getchar());
- if (!feof(fileIn)) putchar(getc(fileIn));
- if (Button()) break;
- }
- }
- else
- {
- printf("\rCould Not Open Output");
- getchar();
- ExitToShell();
- }
- }
-